import {Component, OnInit} from '@angular/core';
import {ListMesTypeComponent} from '../list-mes-type.component';
import {Zero3Option} from '../../../../../frame/enum/zero3-option';
import {MesTypeCondition} from '../../mes-type.type';
import * as fa from '@fortawesome/free-solid-svg-icons';

@Component({
    selector: 'app-search-list-mes-type',
    templateUrl: './search-list-mes-type.component.html',
    styleUrls: ['./search-list-mes-type.component.css']
})
export class SearchListMesTypeComponent implements OnInit {

    // func = this.upper.func;

    zero3Option = Zero3Option;

    condition = new MesTypeCondition();

    extend = {
        keyup: (event) => {
            // T-O-D-O 51 # err
            if (event.keyCode > 32 || event.keyCode === 8) {
                this.listMesType.func.list.click(event);
            }
        },
        condition: {
            upper: {
                type: '',
                icon: fa.faSearchPlus,
                nickname: '上级对象',
                value: () => {
                    return this.condition.upper;
                },
                keyup: (event) => {
                    this.condition.upper = event.target.value;
                    this.extend.keyup(event);
                }
            },
            serNum: {
                icon: fa.faPen,
                nickname: '消息类型编号',
                value: () => {
                    return this.condition.serNum;
                },
                keyup: (event) => {
                    this.condition.serNum = event.target.value;
                    this.extend.keyup(event);
                }
            },
            creator: {
                icon: fa.faUserAlt,
                nickname: '创建者',
                value: () => {
                    return this.condition.creator;
                },
                keyup: (event) => {
                    this.condition.creator = event.target.value;
                    this.extend.keyup(event);
                }
            },
        },
    };

    constructor(public listMesType: ListMesTypeComponent) {
        listMesType.search = this;
    }

    ngOnInit() {
    }

}
